﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.ServiceModel;

namespace ChatService
{
    class Program
    {
        static void Main(string[] args)
        {
            //Uri uri = new Uri(ConfigurationManager.AppSettings["addr"]);
            //ServiceHost host = new ServiceHost(typeof(ChatService), uri);
            //host.Open();
            //Console.WriteLine("Chat service listen on endpoint {0}", uri.ToString());
            //Console.WriteLine("Press ENTER to stop chat service...");
            //Console.ReadLine();
            //host.Abort();
            //host.Close();
            Uri uri = new Uri("net.pipe://localhost");
            using (ServiceHost host = new ServiceHost(typeof(ChatService),
                new Uri[]{
                    uri
                }))
            {
                host.AddServiceEndpoint(typeof(IChatService), new NetNamedPipeBinding(), "ChatService");
                host.Open();
                Console.WriteLine("Chat service listen on endpoint {0}", uri.ToString());
                Console.WriteLine("Press ENTER to stop chat service...");
                Console.ReadLine();
                host.Abort();
                host.Close();
            }
        }
    }
}
